<div class="think-box-shadow">
    <table id="TagsData" data-url="{:sysuri()}" data-target-search="#TagsDataSearch"></table>
</div>

<script>
    $(function () {
        $('#TagsData').layTable({
            even: true, height: 'full',
            sort: {field: 'id desc', type: 'desc'},
            where: {zc_id: '{$zc_id}'},
            cols: [[
                {field: 'id', title: 'ID', width: 80, align: 'center', sort: true},
                {field: 'content', title: '政策名称', minWidth: 100},
                {field: 'tags_txt', title: '绑定标签', minWidth: 100},
                {toolbar: '#TagsTpl', title: '绑定标签', minWidth: 100, align: 'center', fixed: 'right'},
            ]]
        });

        // 数据状态切换操作
        layui.form.on('switch(StatusSwitchTagsData)', function (obj) {
            var data = {id: obj.value, status: obj.elem.checked > 0 ? 1 : 0};
            $.form.load("{:url('state')}", data, 'post', function (ret) {
                if (ret.code < 1) $.msg.error(ret.info, 3, function () {
                    $('#TagsData').trigger('reload');
                });
                return false;
            }, false);
        });
    });
</script>


<script type="text/html" id="TagsTpl">
    <div class="layui-form-item layui-inline">
        <button class="layui-btn" data-title="政策绑定标签" data-width="960px"
                data-modal="{:url('edit')}?zc_id={$zc_id}&id={{d.id}}"
                type="button">
            绑定
        </button>
    </div>
</script>


<!-- 列表排序权重模板 -->
<script type="text/html" id="SortInputTagsDataTplModal">
    <input type="number" min="0" data-blur-number="0" data-action-blur="{:sysuri()}"
           data-value="id#{{d.id}};action#sort;sort#{value}" data-loading="false" value="{{d.sort}}"
           class="layui-input text-center">
</script>

<!-- 操控面板的模板 -->
<script type="text/html" id="ToolbarTagsData">

    {if auth("edit")}
    <a class="layui-btn layui-btn-sm" data-title="编辑数据"
       data-modal='{:url("edit")}?id={{d.id}}&chanpin_id={{chanpin_id}}'>编 辑</a>
    <a class="layui-btn layui-btn-sm" data-title="编辑数据" data-modal='{:url("edit")}' data-value="id#{{d.id}}">编 辑</a>
    {/if}

    {if auth("remove")}
    <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除此吗？" data-action="{:url('remove')}"
       data-value="id#{{d.id}}">删 除</a>
    {/if}
</script>

